package com.moinut.studentattendancemanager.model.dao.proxy;

import com.moinut.studentattendancemanager.model.dao.IAttendanceInfoDAO;
import com.moinut.studentattendancemanager.model.dao.impl.AttendanceInfoDAOImpl;
import com.moinut.studentattendancemanager.model.vo.AttendanceInfo;

import java.util.List;

/**
 * @author MOILING
 */
public class AttendanceInfoDAOProxy extends BaseDAOProxy<AttendanceInfoDAOImpl> implements IAttendanceInfoDAO {
    @Override
    public List<AttendanceInfo> getAttendancesInfoByCourseId(String courseId) throws Exception {
        List<AttendanceInfo> attendancesInfo = this.dao.getAttendancesInfoByCourseId(courseId);
        this.databaseConnection.close();
        return attendancesInfo;
    }

    @Override
    public List<AttendanceInfo> getAttendancesInfoByCourseIdAndStudentId(String courseId, String studentId) throws Exception {
        List<AttendanceInfo> attendancesInfo = this.dao.getAttendancesInfoByCourseIdAndStudentId(courseId, studentId);
        this.databaseConnection.close();
        return attendancesInfo;
    }

    @Override
    public List<AttendanceInfo> getAllAttendancesInfo() throws Exception {
        List<AttendanceInfo> attendancesInfo = this.dao.getAllAttendancesInfo();
        this.databaseConnection.close();
        return attendancesInfo;
    }

    @Override
    public List<AttendanceInfo> getAttendancesInfoByTeacherId(String teacherId) throws Exception {
        List<AttendanceInfo> attendancesInfo = this.dao.getAttendancesInfoByTeacherId(teacherId);
        this.databaseConnection.close();
        return attendancesInfo;
    }

    @Override
    public boolean updateAttendanceInfo(AttendanceInfo attendanceInfo) throws Exception {
        boolean flag = this.dao.updateAttendanceInfo(attendanceInfo);
        this.databaseConnection.close();
        return flag;
    }

    @Override
    public boolean insertAttendanceInfo(AttendanceInfo attendanceInfo) throws Exception {
        boolean flag = this.dao.insertAttendanceInfo(attendanceInfo);
        this.databaseConnection.close();
        return flag;
    }

    @Override
    AttendanceInfoDAOImpl setDAOImpl() {
        return new AttendanceInfoDAOImpl(this.databaseConnection.getConnection());
    }
}
